package com.central.scheduler.api.service.impl;

import com.central.scheduler.api.service.IMonitorService;
import com.central.scheduler.api.utils.RegistryCenterUtils;
import com.central.scheduler.dao.entity.Server;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Tindy
 * @date 2021/12/15
 * @describe
 */
@Service
public class MonitorServiceImpl implements IMonitorService {
    /**
     * query master list
     *
     * @return master information list
     */
    @Override
    public List<Server> queryMaster() {
        return getServerListFromRegistry(true);
    }
    @Override
    public List<Server> getServerListFromRegistry(boolean isMaster) {
        return isMaster ? RegistryCenterUtils.getMasterServers() : RegistryCenterUtils.getWorkerServers();
    }
}
